package tech.xs.entity;

import java.util.Date;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Past;

import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

public class User {
	private Integer id; // 用户ID
	@NotEmpty(message = "用户编码不能为空！")

	private String userCode; // 用户编码
	@NotEmpty(message = "用户名称不能为空！")

	private String userName; // 用户名称
	@Length(min = 6, max = 10, message = "用户密码长度6-10位！")

	private String userPassword; // 用户密码

	private Integer gender; // 性别（1:女、 2:男）

	@Past(message = "必须是一个过去的时间！")

	@DateTimeFormat(pattern = "yyyy-MM-dd")
	private Date birthday; // 出生日期

	@NotEmpty(message = "用户号码不能为空！")
	private String phone; // 手机

	@NotEmpty(message = "用户名地址不能为空！")
	private String address; // 地址

	private Integer userRole; // 用户角色（取自角色表-角色id）

	private Integer createdBy; // 创建者（userId）
	private Date creationDate; // 创建时间
	private Integer modifyBy; // 更新者（userId）
	private Date modifyDate; // 更新时间

	@SuppressWarnings("unused")
	private Integer age; // 年龄

	private String idPicPath; // 证件照片

	private String workPicPath; // 工作证照片

	public String getWorkPicPath() {
		return workPicPath;
	}

	public void setWorkPicPath(String workPicPath) {
		this.workPicPath = workPicPath;
	}

	public String getIdPicPath() {
		return idPicPath;
	}

	public void setIdPicPath(String idPicPath) {
		this.idPicPath = idPicPath;
	}

	@SuppressWarnings("deprecation")
	public Integer getAge() {
		Date date = new Date();
		Integer age = date.getYear() - birthday.getYear();
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getUserCode() {
		return userCode;
	}

	public void setUserCode(String userCode) {
		this.userCode = userCode;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

	public Integer getGender() {
		return gender;
	}

	public void setGender(Integer gender) {
		this.gender = gender;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Integer getUserRole() {
		return userRole;
	}

	public void setUserRole(Integer userRole) {
		this.userRole = userRole;
	}
	
	public Integer getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(Integer createdBy) {
		this.createdBy = createdBy;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public Integer getModifyBy() {
		return modifyBy;
	}

	public void setModifyBy(Integer modifyBy) {
		this.modifyBy = modifyBy;
	}

	public Date getModifyDate() {
		return modifyDate;
	}

	public void setModifyDate(Date modifyDate) {
		this.modifyDate = modifyDate;
	}

	public User() {
		super();
	}

	public User(Integer id, @NotEmpty(message = "用户编码不能为空！") String userCode,
			@NotEmpty(message = "用户名称不能为空！") String userName,
			@Length(min = 6, max = 10, message = "用户密码长度6-10位！") String userPassword, Integer gender,
			@Past(message = "必须是一个过去的时间！") Date birthday, @NotEmpty(message = "用户号码不能为空！") String phone,
			@NotEmpty(message = "用户名地址不能为空！") String address, Integer userRole, Integer createdBy, Date creationDate,
			Integer modifyBy, Date modifyDate, String idPicPath, String workPicPath) {
		super();
		this.id = id;
		this.userCode = userCode;
		this.userName = userName;
		this.userPassword = userPassword;
		this.gender = gender;
		this.birthday = birthday;
		this.phone = phone;
		this.address = address;
		this.userRole = userRole;
		this.createdBy = createdBy;
		this.creationDate = creationDate;
		this.modifyBy = modifyBy;
		this.modifyDate = modifyDate;
		this.idPicPath = idPicPath;
		this.workPicPath = workPicPath;
	}

	@Override
	public String toString() {
		return "User [id=" + id + ", userCode=" + userCode + ", userName=" + userName + ", userPassword=" + userPassword
				+ ", gender=" + gender + ", birthday=" + birthday + ", phone=" + phone + ", address=" + address
				+ ", userRole=" + userRole + ", createdBy=" + createdBy + ", creationDate=" + creationDate
				+ ", modifyBy=" + modifyBy + ", modifyDate=" + modifyDate + ", idPicPath=" + idPicPath
				+ ", workPicPath=" + workPicPath + "]";
	}

	
}
